#include "ButtonInput.h"


ButtonInput::ButtonInput(int x, int y, std::string label, void (*funct) (void))
{
	this->funct = funct;
		value = "";
	prop = "";
	value =label;
	font = TTF_OpenFont( "DroidSerif-Regular.ttf", 32 );

	textColor = new SDL_Color(); 
	textColor->b = 255;
	textColor->g = 255;
	textColor->r = 255;
	//Enable Unicode
    SDL_EnableUNICODE( SDL_ENABLE );
	  inner = new SDL_Rect();
	inner->h=32;
	inner->w = 120;
	inner->x = x;
	inner->y =y;
	outer = new SDL_Rect();
	outer->h = 36;
	outer->w = 134;
	outer->x = x-2;
	outer->y = y -2;
	isActive = false;
	//Render a new text surface
            text = TTF_RenderText_Solid( font, value.c_str(), *textColor );

}


ButtonInput::~ButtonInput(void)
{
}

void ButtonInput::onClick()
{
	if((*this).funct != NULL)
	{
		funct();
	}
}
	
void ButtonInput::onClickOut()
{

}
void ButtonInput::drawElement(SDL_Surface* screen)
{
		int x = (inner->x +2  );
	int y = (inner->y +2 );
	
	SDL_FillRect( screen, outer, SDL_MapRGB( screen->format, 0x00, 0x00, 0x00 ) );
	
	
	SDL_FillRect( screen, inner, SDL_MapRGB( screen->format, 0x33, 0x33, 0x33 ) );
	//Draw::apply_surface( x, y, box, screen );
	 if( text != NULL )
    {
        //Show the name
        Draw::apply_surface( x, y, text, screen );
    }
}
void ButtonInput::handleInput(SDL_Event event)
{

}